<template>
  <a-modal :maskClosable="false" :open="visible" title="添加分类" @ok="handleOk" @cancel="$emit('update:open', false)" @update:open="$emit('update:open', $event)">
    <a-form :model="form" layout="vertical">
      <a-form-item label="分类名称" name="name">
        <a-input v-model:value="form.name" />
      </a-form-item>
    </a-form>
  </a-modal>
</template>

<script setup>
import { ref } from 'vue'

const props = defineProps({
  visible: Boolean
})

const emit = defineEmits(['update:open', 'submit'])

const form = ref({
  name: ''
})

const handleOk = () => {
  emit('submit', form.value.name)
  form.value.name = ''
}
</script>
